<?php
if(empty($_SESSION['userIdForgotUsernameSess']))
header("Location:index.php?notFound");
else
{
$userId=$_SESSION['userIdForgotUsernameSess'];
$sqlSelUsr="SELECT * FROM tbl_users WHERE user_id='$userId' and status =1";
$rstSelUsr=mysql_query($sqlSelUsr);
$noSelUsr=mysql_num_rows($rstSelUsr);
if($noSelUsr>0)
{
$rowSelUsr=mysql_fetch_array($rstSelUsr);
$secretQuestionId=$rowSelUsr['secret_question'];
$userType=$rowSelUsr['user_type'];
$sqlSelQuestion="SELECT question FROM tbl_questions WHERE question_id='$secretQuestionId'";
$rstSelQuestion=mysql_query($sqlSelQuestion);
$noSelQuestion=mysql_num_rows($rstSelQuestion);
if($noSelQuestion>0)
{
$rowSelQuestion=mysql_fetch_array($rstSelQuestion);
$secretQuestion=$rowSelQuestion['question'];
}
}
}
if(!empty($_POST['submit']))
{
$flag=0;
if(!empty($_REQUEST['secretAnswer']))
{
$flag=$flag+1;
$sqlSelPwdConfirm=" secret_answer='".$_REQUEST['secretAnswer']."' and";
}
if(!empty($_REQUEST['zip']))
{
$flag=$flag+1;
$sqlSelPwdConfirm.=" zip='".$_REQUEST['zip']."' and";
}
/*if(!empty($_REQUEST['phoneNumber']))
{
$flag=$flag+1;
$sqlSelPwdConfirm.=" phone_number_1='".$_REQUEST['phoneNumber']."' and";
}*/
/*if(!empty($_REQUEST['dYear']) && !empty($_REQUEST['dMonth']) && !empty($_REQUEST['dDay']))
{
$flag=$flag+1;
$sqlSelPwdConfirm.=" dob='".$_REQUEST['dYear']."/".$_REQUEST['dMonth']."/".$_REQUEST['dDay']."' and";
}*/
$count=strlen($sqlSelPwdConfirm);
$sqlSelPwdConfirm=substr($sqlSelPwdConfirm,0,($count-3));
if($flag>=2)
{
$sqlSelPwdConfirm="SELECT username FROM tbl_users WHERE ".$sqlSelPwdConfirm;
$rstSelPwdConfirm=mysql_query($sqlSelPwdConfirm);
$noSelPwdConfirm=mysql_num_rows($rstSelPwdConfirm);
if($noSelPwdConfirm>0)
{
$rowSelPwdConfirm=mysql_fetch_array($rstSelPwdConfirm);
$username=$rowSelPwdConfirm['username'];
$_SESSION['userUsernameForgotUsernameSess']=$username;
header("Location:index.php?usernameChange");
}
else
  $msg = "<font face=verdana size=2 color='#FF0000'><b>Invalid answers, Please enter valid answers for below questions </b></font>";
}
else
 $msg = "<font face=verdana size=2 color='#FF0000'><b>Please enter valid answers for below questions </b></font>";
}
?>
<div id='panel'>
   <div class="fulldiv" style="width:700px;">

 <div class="fulldiv" style="margin:10px 0px 0px 0px;">
	
<div style="float:left; margin:0px 10px 0px 10px;"><strong class="orangehead">Confirm your identity to reset Username </strong></div>

<div class="fullbox_top">&nbsp;</div>
	<div class="fullbox_repeat">
<form name="frmPasswordConfirmMember" id="frmPasswordConfirmMember" method="post" action="<?php echo $_SERVER['php_self']?> " onSubmit="return validateConfirmPassword()">
<table width="100%" border="0" class="contentForm"  cellpadding="0" cellspacing="0">
  <tr>
    <td width="35%" class="contentHeader">&nbsp;</td>
  </tr>
  <tr>
    <td>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td></td>
    <td  height="10"></td>
  </tr>
  <tr>
    <td width="2%"></td>
    <td width="98%"  height="16">Answer two or more of the following questions correctly.</td>
  </tr>
  <tr>
    <td></td>
    <td  height="10"></td>
  </tr>
  <tr>
    <td></td>
    <td  height="10"></td>
  </tr>
  <tr>
    <td></td>
    <td  height="16"><div id="messageArea">
      <?php if(isset($msg))
	  echo "<b>".$msg."</b>";
										
		?>
    </div></td>
  </tr>
  
  <tr>
    <td></td>
    <td  height="10"></td>
  </tr>
  
  <tr>
    <td>&nbsp;</td>
    <td><div id="lblSecretQuestion"><?php echo $secretQuestion; ?></div>
        <input type="text" name="secretAnswer" id="secretAnswer" class="inputbg" />
        <div  class="boldGreyNotes">
           Answer the secret question you provided.<br />
          </div>    </td>
  </tr>
  <tr>
    <td></td>
    <td  height="10"></td>
  </tr>
 
  <tr>
    <td>&nbsp;</td>
    <td><div id="lblzip">ZIP code/ Postal code</div>
        <input type="text" name="zip" id="zip" class="inputbg"></td>
  </tr>
  
  
 <!-- <tr>
    <td>&nbsp;</td>
    <td><div id="lblPhoneNumber">Your phone number</div>
        <input type="text" name="phoneNumber" id="phoneNumber">
        <div  class="boldGreyNotes">
          Provide the primary phone number that's associated with your account. <br />Please enter your phone number and include dashes: example 232-566-3456         </div>  </td>
  </tr>-->
  <?php //if($userType=='1' || $userType=='2')
  //{ ?>
  <tr>
    <td></td>
    <td  height="10"></td>
  </tr>
  
  <!--<tr>
    <td>&nbsp;</td>
    <td><div id="lblDOB">Your birth date</div>
            <select name="dMonth" id="dMonth" style="width:100px">
              <option value="">--Month--</option>
              <option value="01">January</option>
              <option value="02">February</option>
              <option value="03">March</option>
              <option value="04">April</option>
              <option value="05">May</option>
              <option value="06">June</option>
              <option value="07">July</option>
              <option value="08">August</option>
              <option value="09">September</option>
              <option value="10">October</option>
              <option value="11">November</option>
              <option value="12">December</option>
            </select>
            <select name="dDay" id="dDay" style="width:80px">
              <option value="">--Day--</option>
              <option value="01">01</option>
              <option value="02">02</option>
              <option value="03">03</option>
              <option value="04">04</option>
              <option value="05">05</option>
              <option value="06">06</option>
              <option value="07">07</option>
              <option value="08">08</option>
              <option value="09">09</option>
              <option value="10">10</option>
              <option value="11">11</option>
              <option value="12">12</option>
              <option value="13">13</option>
              <option value="14">14</option>
              <option value="15">15</option>
              <option value="16">16</option>
              <option value="17">17</option>
              <option value="18">18</option>
              <option value="19">19</option>
              <option value="20">20</option>
              <option value="21">21</option>
              <option value="22">22</option>
              <option value="23">23</option>
              <option value="24">24</option>
              <option value="25">25</option>
              <option value="26">26</option>
              <option value="27">27</option>
              <option value="28">28</option>
              <option value="29">29</option>
              <option value="30">30</option>
              <option value="31">31</option>
              </select>
          </select>
          <input type="dYear" name="dYear" id="dYear" value="YYYY" onClick="this.value=''" size="4" maxlength="4" /></td>
  </tr>-->
  <tr>
    <td></td>
    <td  height="10"></td>
  </tr>
  <?php// } ?>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type="submit" name="submit" id="submit" value="Continue" class="sbmt_btn" /></td>
  </tr>
  <tr>
    <td></td>
    <td  height="10"></td>
  </tr>
</table>
</td>
</tr>
</table>
</form>
</div>
<div class="fullbox_bot">&nbsp;</div>

</div>

</div>
<br />